package king{
	
	/*
	QQ: 334973991
	*/
	import flash.events.*;
	import flash.net.*;
	public class MyDateLoader{
		private var completefunction:Function;
		public function MyDateLoader(completefunction:Function){
			this.completefunction=completefunction;
		}
		public function loadXml(myUrl:String):void{
			var requests:URLRequest = new URLRequest();
			requests.url=myUrl;
			requests.method=URLRequestMethod.GET;
			var loader:URLLoader =new URLLoader();
			loader.addEventListener(Event.COMPLETE,completeHandler);
			loader.addEventListener(IOErrorEvent.IO_ERROR,cancel);
			try {
				loader.load(requests);
			} catch (error:Error){
				trace("页面请求错误");
				erro(error.toString());
			}
		}
		private function cancel(events:IOErrorEvent):void{
			trace("系统发生错误");
			erro(events.toString());
		}
		private function completeHandler(events:Event):void{
			completefunction(events.target.data);
			trace("load success");
		}
		private function erro(erroStr:String):void{
			trace(erroStr);
		}
	}
}
